/*****************************************************************************
 * plum_ioctl.h
 *
 * Copyright (C) 2020 Jeasonvor 1101627719@qq.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/
#ifndef __PLUM_IOCTL_H__
#define __PLUM_IOCTL_H__

/*****************************************************************************
 * Included Files
 ****************************************************************************/

/*****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/

// TCP/IP
#define PLUM_TCPIP_IOCTL_BASE   0x00000000
#define PLUM_TCPIP_IOCTL_SOCKET (PLUM_TCPIP_IOCTL_BASE + 1)
#define PLUM_TCPIP_IOCTL_BIND   (PLUM_TCPIP_IOCTL_BASE + 2)
#define PLUM_TCPIP_IOCTL_LISTEN (PLUM_TCPIP_IOCTL_BASE + 3)
#define PLUM_TCPIP_IOCTL_ACCEPT (PLUM_TCPIP_IOCTL_BASE + 4)
#define PLUM_TCPIP_IOCTL_CON    (PLUM_TCPIP_IOCTL_BASE + 5)
#define PLUM_TCPIP_IOCTL_READ   (PLUM_TCPIP_IOCTL_BASE + 6)
#define PLUM_TCPIP_IOCTL_WRITE  (PLUM_TCPIP_IOCTL_BASE + 7)
#define PLUM_TCPIP_IOCTL_CLOSE  (PLUM_TCPIP_IOCTL_BASE + 8)

// MQTT
#define PLUM_MQTT_IOCTL_BASE   0x00000100
#define PLUM_MQTT_IOCTL_CON    (PLUM_MQTT_IOCTL_BASE + 1)
#define PLUM_MQTT_IOCTL_DISCON (PLUM_MQTT_IOCTL_BASE + 2)
#define PLUM_MQTT_IOCTL_PUB    (PLUM_MQTT_IOCTL_BASE + 3)
#define PLUM_MQTT_IOCTL_SUB    (PLUM_MQTT_IOCTL_BASE + 4)
#define PLUM_MQTT_IOCTL_UNSUB  (PLUM_MQTT_IOCTL_BASE + 5)
#define PLUM_MQTT_IOCTL_MSG_CB (PLUM_MQTT_IOCTL_BASE + 6)
#define PLUM_MQTT_IOCTL_YIELD  (PLUM_MQTT_IOCTL_BASE + 7)

// HTTP
#define PLUM_HTTP_IOCTL_BASE 0x00000200
#define PLUM_HTTP_IOCTL_GET  (PLUM_HTTP_IOCTL_BASE + 1)

// PUBLIC
#define PLUM_PUBLIC_IOCTL_BASE     0x00000300
#define PLUM_PUBLIC_IOCTL_GET_SVER (PLUM_DEV_IOCTL_BASE + 1)
#define PLUM_PUBLIC_IOCTL_GET_HWER (PLUM_DEV_IOCTL_BASE + 2)
#define PLUM_PUBLIC_IOCTL_GET_MAC  (PLUM_DEV_IOCTL_BASE + 3)
#define PLUM_PUBLIC_IOCTL_TURN_ON  (PLUM_DEV_IOCTL_BASE + 4)
#define PLUM_PUBLIC_IOCTL_TURN_OFF (PLUM_DEV_IOCTL_BASE + 5)

// Sensor
#define PLUM_SENSOR_IOCTL_STEPER_BASE      0x00000400
#define PLUM_SENSOR_IOCTL_STEPER_SPD_START (PLUM_SENSOR_IOCTL_STEPER_BASE + 1)
#define PLUM_SENSOR_IOCTL_STEPER_ANG_START (PLUM_SENSOR_IOCTL_STEPER_BASE + 2)
#define PLUM_SENSOR_IOCTL_STEPER_STOP      (PLUM_SENSOR_IOCTL_STEPER_BASE + 3)

/*****************************************************************************
 * Public Types
 ****************************************************************************/

// TCP/IP
typedef struct {
    plum_u32 fd;
} plum_tcpip_ioctl_socekt_t;

typedef struct {
    plum_u32 fd;
} plum_tcpip_ioctl_bind_t;

typedef struct {
    plum_u32 fd;
} plum_tcpip_ioctl_listen_t;

typedef struct {
    plum_u32 fd;
} plum_tcpip_ioctl_accept_t;

typedef struct {
    plum_u32 fd;
} plum_tcpip_ioctl_con_t;

typedef struct {
    plum_u32 fd;
} plum_tcpip_ioctl_read_t;

typedef struct {
    plum_u32 fd;
} plum_tcpip_ioctl_write_t;

typedef struct {
    plum_u32 fd;
} plum_tcpip_ioctl_close_t;

// MQTT
typedef struct {
    plum_s8 *clentid;
    plum_s8 *url;
    plum_u32 port;
    plum_s8 *usrname;
    plum_s8 *password;
    plum_u8  qos;
} plum_mqtt_ioctl_con_t;

typedef struct {
    plum_s8 *reserve;
} plum_mqtt_ioctl_discon_t;

typedef struct {
    plum_s8 *topic;
    plum_s8 *payload;
} plum_mqtt_ioctl_pub_t;

typedef struct {
    plum_s8 *topic;
} plum_mqtt_ioctl_sub_t;

typedef struct {
    plum_s8 *topic;
} plum_mqtt_ioctl_unsub_t;

typedef struct {
    plum_void (*handler)(plum_s8 *topic, plum_s8 *payload, plum_u16 pyloadlen);
} plum_mqtt_ioctl_msg_t;

typedef struct {
    plum_s8 *reserve;
} plum_mqtt_ioctl_yield_t;

// HTTP

// PUBLIC

// SENSOR
typedef struct {
    /** 传感器ID **/
    plum_u32 id;
    /** 反向：0.正向，1.反向 **/
    plum_u32 direction;
    /** 速度 **/
    plum_u32 speed;
} plum_sensor_ioctl_steper_spd_start_t;

typedef struct {
    /** 传感器ID **/
    plum_u32 id;
    /** 反向：0.正向，1.反向 **/
    plum_u32 direction;
    /** 角度 **/
    plum_float angle;
} plum_sensor_ioctl_steper_ang_start_t;

typedef struct {
    /** 传感器ID **/
    plum_u32 id;
} plum_sensor_ioctl_steper_stop_t;

/*****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* __PLUM_IOCTL_H__ */
/****************************************************************************/
/*                                                                          */
/*  End of file.                                                            */
/*                                                                          */
/****************************************************************************/
